package com.neutech.neusys.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neutech.neusys.mapper.DepartmentMapper;
import com.neutech.neusys.mapper.InsFmedMapper;
import com.neutech.neusys.mapper.SelExpMapper;
import com.neutech.neusys.mapper.SelFmedMapper;
import com.neutech.neusys.po.Department;
import com.neutech.neusys.service.FmedService;
import com.neutech.po.ExpenseClass;
import com.neutech.po.Fmeditem;
import com.neutech.vo.FmedVo;
@Service
public class FmedServiceImpl implements FmedService {
	@Autowired
	private SelFmedMapper selFmedMapper;
	@Autowired
	private InsFmedMapper insFmedMapper;
	@Autowired
	private SelExpMapper selExpMapper;
	@Autowired
	private DepartmentMapper departmentMapper;
	@Override
	public FmedVo selectAll(Map<String,Object> map) {
		// 前端穿的页码数转为数字并减一，计算limit起始数据值，替换原有值
		String pageNumber = (String)map.get("pageNumber");
		try {
			Integer pn = new Integer(pageNumber);
			pn = pn-1;
			if(pn < 0){
				pn = 0;
			}
			pn *= 10;
			map.put("pageNumber", pn);
		} catch (Exception e) {
			// TODO: handle exception
			map.put("pageNumber", 0);
		}
		FmedVo vo = new FmedVo();
		vo.setMap(selFmedMapper.selectAll(map));
		vo.setTotalNumber(selFmedMapper.selectAllCount(map));
		return vo;
	}

	@Override
	public int InsFmed(Fmeditem fmed) {
		// TODO Auto-generated method stub
		return insFmedMapper.InsFmed(fmed);
	}

	@Override
	public List<ExpenseClass> selectExp() {
		// TODO Auto-generated method stub
		return selExpMapper.selectExp();
	}

	@Override
	public List<Department> selectdep() {
		// TODO Auto-generated method stub
		return departmentMapper.queryAll();
	}

	@Override
	public int updatefmed(Map<String, Object> fmed) {
		// TODO Auto-generated method stub
		return insFmedMapper.updatefmed(fmed);
	}

	@Override
	public int delById(Fmeditem fmed) {
		// TODO Auto-generated method stub
		return insFmedMapper.delById(fmed);
	}

}
